<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <script>
    let P1 = () => {
      return new Promise((resolve, reject) => {
        let xhr = new XMLHttpRequest();
        xhr.onreadystatechange = () => {
          if (xhr.readyState != 4) return;
          if (xhr.readyState == 4 && xhr.status == 200) {
            resolve(xhr.responseText);
          } else {
            reject("服务器错误");
          };
        };
        xhr.open("get", null);
        xhr.send(null);
      });
    };
    P1("??").then((data) => {
      console.log(data);
    }, (info) => {
      console.log(info);
    });
  </script>
</body>

</html>